﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace TrenchcoatRobots.Datatypes.Input {
	/// <summary>
	/// Class for Inputs of Gamepad keys. Only keys are supported (in a boolean state).
	/// </summary>
	class GamePadInput : GameInput{
		public Buttons PositiveKey { get; set; }
		public Buttons NegativeKey { get; set; }
		bool useNegative;

		public override void Update( ref GamePadState gps ) {
			base.Value = 0;
			if ( gps.IsButtonDown( PositiveKey ) ) {
				base.Value += 1;
			}
			if ( useNegative ) {
				if ( gps.IsButtonDown( NegativeKey ) ) {
					base.Value -= 1;
				}
			}
		}

		public GamePadInput( Buttons positiveKey, string name)
			: base(name) {
				PositiveKey = positiveKey;
				useNegative = false;
		}
		public GamePadInput( Buttons positiveKey, Buttons negativeKey, string name)
			: base(name) {
			PositiveKey = positiveKey;
			NegativeKey = negativeKey;
			useNegative = true;
		}
	}
}
